<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "shop".
 *
 * @property integer $s_id
 * @property string $s_name
 * @property string $s_pass
 * @property string $dianname
 * @property string $s_dizi
 * @property string $shenhe
 * @property string $type
 * @property string $s_logo
 * @property string $phone
 * @property string $back_img
 *
 * @property Goods[] $goods
 * @property ScAudit[] $scAudits
 * @property ScTotal[] $scTotals
 */
class Shop extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'shop';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['s_id', 's_name', 's_pass', 'dianname', 's_dizi', 'shenhe', 'type', 's_logo', 'phone', 'back_img'], 'required'],
            [['s_id'], 'integer'],
            [['shenhe', 'phone'], 'number'],
            [['s_name', 'type'], 'string', 'max' => 30],
            [['s_pass'], 'string', 'max' => 16],
            [['dianname'], 'string', 'max' => 40],
            [['s_dizi', 's_logo', 'back_img'], 'string', 'max' => 100]
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            's_id' => '店铺ID',
            's_name' => '店铺名称',
            's_pass' => '店铺密码',
            'dianname' => '店名',
            's_dizi' => '地址',
            'shenhe' => '审核',
            'type' => 'Type',
            's_logo' => 'logo',
            'phone' => '电话',
            'back_img' => 'Back Img',
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getGoods()
    {
        return $this->hasMany(Goods::className(), ['s_id' => 's_id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getScAudits()
    {
        return $this->hasMany(ScAudit::className(), ['s_id' => 's_id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getScTotals()
    {
        return $this->hasMany(ScTotal::className(), ['s_id' => 's_id']);
    }
}
